home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / programm.ing / falcon / nt_dsp1.lzh / NT_DSP1.MSA / CODEC / LOGLIN.ASM < prev    next >
Encoding:
Assembly Source File  |  1989-01-24  |  4.6 KB  |  110 lines

  1. ;
  2. ; This program originally available on the Motorola DSP bulletin board.
  3. ; It is provided under a DISCLAMER OF WARRANTY available from
  4. ; Motorola DSP Operation, 6501 Wm. Cannon Drive W., Austin, Tx., 78735.
  5. ; Companded CODEC to Linear PCM Data Conversion Macros
  6. ; Last Update 20 Apr 87   Version 1.0
  7. ;
  8. loglin  ident   1,0
  9. ;
  10. ; These macros convert 8 bit companded data received from CODEC A/D
  11. ; converters used in telecommunications applications to 13 bit, linear
  12. ; fractional data.  The internal mu/a-law lookup tables in the DSP56001
  13. ; X data ROM are used to minimize execution time.  Three companded
  14. ; formats are supported for the Motorola MC14400 CODEC series and
  15. ; similar devices.
  16. ;
  17. ; Macro Calls:          smlin - sign magnitude to linear conversion
  18. ;                               with mu-law companding.
  19. ;                       mulin - mu-law companded to linear conversion.
  20. ;                       allin - a-law companded to linear conversion
  21. ;                               with CCITT (G7.12) format.
  22. ;
  23. ;                       No macro arguments are required.  However, these
  24. ;                       macros assume that the scaling modes are off
  25. ;                       (S1=0, S0=0).
  26. ;
  27. ; Input data is in the 8 most significant bits of a1.  The remaining
  28. ; bits of a are ignored.
  29. ;
  30. ;  -------------------------------------------------------
  31. ; | Sign |    Chord Number    |       Step Number         |
  32. ; | Bit  |                    |                           |
  33. ; |__23__|__22_____21_____20__|__19_____18_____17_____16__|
  34. ;
  35. ; Output data is in the 56 bit accumulator a.  The linear fraction is
  36. ; in the 13 most significant bits of a1 and the 11 least significant
  37. ; bits are zero.
  38. ;
  39. ; Alters Data ALU Registers
  40. ;       x1      x0
  41. ;       a2      a1      a0      a
  42. ;       b2      b1      b0      b
  43. ;
  44. ; Alters Address Registers
  45. ;       r0
  46. ;
  47. ; Alters Program Control Registers
  48. ;       pc      sr
  49. ;
  50. ; Uses 0 locations on System Stack
  51. ;
  52. ; Latest Revision - April 15, 1987
  53. ; Tested and verified - April 20, 1987
  54. ;
  55. ; smlin - sign magnitude to linear conversion
  56. ;
  57. smlin   macro
  58. _shift  equ     $80                     ;shift constant
  59. _mutable        equ     $100            ;base address of mu-law table
  60. ;
  61.         not     a       a1,b            ;invert input bits, save input
  62.         lsl     a       #>_shift,x0     ;shift out sign bit, get shift constant
  63.         lsr     a       #_mutable,x1    ;shift in zero, get table base
  64.         tfr     x1,a    a1,x1           ;swap table base and offset
  65.         mac     x1,x0,a                 ;shift offset down and add to base
  66.         move            a,r0            ;move to address register
  67.         nop
  68.         lsl     b       x:(r0),a        ;c=sign bit, lookup linear data
  69.         neg     a       a,b             ;a=negative result, b=positive result
  70.         tcs     b,a                     ;if pos sign, correct result
  71.         endm
  72. ;
  73. ; mulin - mu-law to linear conversion
  74. ;
  75. mulin   macro
  76. _shift  equ     $80                     ;shift constant
  77. _mutable        equ     $100            ;base address of mu-law table
  78. ;
  79.         move            a1,b            ;save input
  80.         lsl     a       #>_shift,x0     ;shift out sign bit, get shift constant
  81.         lsr     a       #_mutable,x1    ;shift in zero, get table base
  82.         tfr     x1,a    a1,x1           ;swap table base and offset
  83.         mac     x1,x0,a                 ;shift offset down and add to base
  84.         move            a,r0            ;move to address register
  85.         nop
  86.         lsl     b       x:(r0),a        ;c=sign bit, lookup linear data
  87.         neg     a       a,b             ;a=negative result, b=positive result
  88.         tcs     b,a                     ;if pos sign, correct result
  89.         endm
  90. ;
  91. ; allin - a-law to linear conversion
  92. ;
  93. allin   macro
  94. _shift  equ     $80                     ;shift constant
  95. _atable equ     $180                    ;base address of a-law table
  96. ;
  97.         move            a1,b            ;save input
  98.         lsl     a       #>_shift,x0     ;shift out sign bit, get shift constant
  99.         lsr     a       #_atable,x1     ;shift in zero, get table base
  100.         tfr     x1,a    a1,x1           ;swap table base and offset
  101.         mac     x1,x0,a                 ;shift offset down and add to base
  102.         move            a,r0            ;move to address register
  103.         nop
  104.         lsl     b       x:(r0),a        ;c=sign bit, lookup linear data
  105.         neg     a       a,b             ;a=negative result, b=positive result
  106.         tcs     b,a                     ;if positive sign, correct result
  107.         endm
  108.